package com.numberone.web.controller.bottomurlson;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.numberone.common.annotation.Log;
import com.numberone.common.enums.BusinessType;
import com.numberone.system.domain.BottomUrlSon;
import com.numberone.system.service.IBottomUrlSonService;
import com.numberone.framework.web.base.BaseController;
import com.numberone.common.page.TableDataInfo;
import com.numberone.common.base.AjaxResult;
import com.numberone.common.utils.poi.ExcelUtil;

/**
 * 底部url地址导航栏子级 信息操作处理
 * 
 * @author 于沛麟
 * @date 2020-09-25
 */
@Controller
@RequestMapping("/system/bottomUrlSon")
public class BottomUrlSonController extends BaseController
{
    private String prefix = "system/bottomUrlSon";
	
	@Autowired
	private IBottomUrlSonService bottomUrlSonService;
	
	@RequiresPermissions("system:bottomUrlSon:view")
	@GetMapping()
	public String bottomUrlSon()
	{
	    return prefix + "/bottomUrlSon";
	}
	
	/**
	 * 查询底部url地址导航栏子级列表
	 */
	@RequiresPermissions("system:bottomUrlSon:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(BottomUrlSon bottomUrlSon)
	{
		startPage();
        List<BottomUrlSon> list = bottomUrlSonService.selectBottomUrlSonList(bottomUrlSon);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出底部url地址导航栏子级列表
	 */
	@RequiresPermissions("system:bottomUrlSon:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BottomUrlSon bottomUrlSon)
    {
    	List<BottomUrlSon> list = bottomUrlSonService.selectBottomUrlSonList(bottomUrlSon);
        ExcelUtil<BottomUrlSon> util = new ExcelUtil<BottomUrlSon>(BottomUrlSon.class);
        return util.exportExcel(list, "bottomUrlSon");
    }
	
	/**
	 * 新增底部url地址导航栏子级
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存底部url地址导航栏子级
	 */
	@RequiresPermissions("system:bottomUrlSon:add")
	@Log(title = "底部url地址导航栏子级", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(BottomUrlSon bottomUrlSon)
	{		
		return toAjax(bottomUrlSonService.insertBottomUrlSon(bottomUrlSon));
	}

	/**
	 * 修改底部url地址导航栏子级
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Long id, ModelMap mmap)
	{
		BottomUrlSon bottomUrlSon = bottomUrlSonService.selectBottomUrlSonById(id);
		mmap.put("bottomUrlSon", bottomUrlSon);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存底部url地址导航栏子级
	 */
	@RequiresPermissions("system:bottomUrlSon:edit")
	@Log(title = "底部url地址导航栏子级", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(BottomUrlSon bottomUrlSon)
	{		
		return toAjax(bottomUrlSonService.updateBottomUrlSon(bottomUrlSon));
	}
	
	/**
	 * 删除底部url地址导航栏子级
	 */
	@RequiresPermissions("system:bottomUrlSon:remove")
	@Log(title = "底部url地址导航栏子级", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(bottomUrlSonService.deleteBottomUrlSonByIds(ids));
	}
	
}
